from typing import Final, final

from django.db import models

#: That's how constants should be defined.
_JOB_TITLE_MAX_LENGTH: Final = 80

@final
class ToDo(models.Model):
    """
    Represents a job saved in the database.

    Attrs:
        title - Job name.
        description - Contains the jobs's itself.
        done - Shows if job is already done.
        created_at - The date and time, when this model was created.
        updated_at - The date and time, when this model was last updated.

    """

    title = models.CharField(max_length=_JOB_TITLE_MAX_LENGTH)
    description = models.TextField()
    done = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    # New field!
    objects = models.Manager()

    class Meta(object):
        verbose_name = 'ToDo'
        verbose_name_plural = 'ToDos'

    def __str__(self) -> str:
        """All django models should have this method."""
        return '<ToDo: {0}>'.format(self.title)
